/*
 * wordCount.cpp
 *
 *  Created on: Aug 21, 2012
 *      Author: jh238d
 */
#include <iostream>
#include <string>
#include <regex>
#include <hash_map>
using namespace std;

int wordCount(string str)
{
	if(str.length()==0) return 0;
	regex e("\\w");
	smatch sm;
	regex_match(str,sm,e);
	hash_map<string, int> map;
	typedef pair<string, int> Pair;
	for(int i=0; i<sm.size();i++){
		if(map.find(sm[i])==map.end())
			map.insert(Pair(sm[i],0));
		else
			map[sm[i]]++;
	}
	int maxCount=0;
	for(int i=0; i<sm.size();i++)
		if(map[sm[i]]>maxCount)
			maxCount = map[sm[i]];
	return maxCount;
}

//int main(){
//	string s = "This is absolutely a test string.";
//	cout<<wordCount(s)<<endl;
//	return 0;
//}



